<?php
class Veneer_Plugin extends Zend_Controller_Plugin_Abstract
{
	/*
    public function routeStartup(Zend_Controller_Request_Abstract $request)
    {
        $this->getResponse()->appendBody("<p>routeStartup() called</p>\n");
    }

    public function routeShutdown(Zend_Controller_Request_Abstract $request)
    {
        $this->getResponse()->appendBody("<p>routeShutdown() called</p>\n");
    }

    public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
    {
        $this->getResponse()->appendBody("<p>dispatchLoopStartup() called</p>\n");
    }

    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $this->getResponse()->appendBody("<p>preDispatch() called</p>\n");
    }

    public function postDispatch(Zend_Controller_Request_Abstract $request)
    {
        $this->getResponse()->appendBody("<p>postDispatch() called</p>\n");
    }
*/
	public function dispatchLoopShutdown()
    {
/*
	If the registry says to cache the page, this will do so.
*/


		$registry = Zend_Registry::getInstance();
		$debug = $registry->get('veneer_debug');
		$msite_config = $registry->get('msite_config');
		if($msite_config->main->cacheOn==1) {
			$debug->comment("msite_config->main->cacheOn=1");

			if(isset($registry['NoCache'])) {
				$debug->comment("Cache Bypassed");
			} else {

				$veneer_parms = $registry->get('veneer_parms');
				$body = $this->getResponse()->getBody();
				$cache = $registry->get('veneer_cache');
				$cache->pgSave($body);
				$debug->comment("This page is saved in Cache");
			}
		}

        $this->getResponse()->appendBody($debug->echoLog());

    }
}